package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_backend_facade.vo.WithdrawalRecordVO;
import com.yxw.live_vod_boot.dto.BalanceDetailAddDTO;
import com.yxw.live_vod_boot.dto.BalanceDetailQueryDTO;
import com.yxw.live_vod_boot.service.BalanceDetailService;
import com.yxw.live_vod_boot.vo.BalanceDetailVO;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 店铺余额明细
 * @author xiexuxin
 * @date 2024-01-03
 */
@RestController
@Api(value = "店铺余额明细", tags = "店铺余额明细")
@Slf4j
@RequestMapping("/api/balance_detail")
public class BalanceDetailController {

    @Autowired
    private BalanceDetailService balanceDetailService;

    @ApiOperation(value = "新增余额明细")
    @PostMapping(value = "/add_balance_detail")
    public BaseResult addBalanceDetail(@RequestBody @Validated BalanceDetailAddDTO dto) {
        balanceDetailService.addBalanceDetail(dto);
        return BaseResult.doSuccess(null, "添加成功");
    }

    @ApiOperation(value = "获取提现记录详情")
    @PostMapping(value = "/api/withdrawal_record/get_withdrawal_record_by_id")
    public BaseResult<WithdrawalRecordVO> getWithdrawalRecordById(@RequestParam("id") Long id){
        return balanceDetailService.getWithdrawalRecordById(id);
    }

    @ApiOperation(value = "余额明细列表查询")
    @PostMapping(value = "/get_balance_detail_list")
    public BaseResult<PageVO<List<BalanceDetailVO>>> getBalanceDetailList(@RequestBody BalanceDetailQueryDTO dto) {
        PageVO<List<BalanceDetailVO>> pageVO = balanceDetailService.getBalanceDetailList(dto);
        return ResultHelper.fillWithSuccess(pageVO);
    }

    @ApiOperation(value = "获取余额明细详情")
    @PostMapping(value = "/get_balance_detail_by_id")
    public BaseResult getBalanceDetailById(@RequestParam("id") Long id) {
        BalanceDetailVO vo = balanceDetailService.getBalanceDetailById(id);
        return BaseResult.doSuccess(vo, "查询成功");
    }
}
